package com.sc.nft.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.admin.vo.ExternalLinkDeleteVO;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.dto.ExternalLinkIconIconUpdateDTO;
import com.sc.nft.entity.dto.ExternalLinkIconPageAdminDTO;
import com.sc.nft.entity.dto.ExternalLinkIconSaveAdminDTO;
import com.sc.nft.entity.vo.ExternalLinkIconPageAdminVO;
import com.sc.nft.service.ExternalLinkIconService;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 外链图标管理表(ExternalLinkIcon)表控制层
 *
 * @author makejava
 * @since 2023-03-06 13:30:27
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/externalLinkIcon")
@Api(tags = "外链图标管理表")
public class ExternalLinkIconController {

    /**
     * 服务对象
     */
    private final ExternalLinkIconService externalLinkIconService;


    @PostMapping(value = "/deleteById", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "删除", notes = "删除", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<ExternalLinkDeleteVO> deleteById(@Validated @RequestBody IdRequest idRequest) {
        ExternalLinkDeleteVO externalLinkDeleteVO = new ExternalLinkDeleteVO();
        externalLinkDeleteVO.setResult(externalLinkIconService.deleteById(idRequest.getId()));
        return Result.success(externalLinkDeleteVO);
    }


    @PostMapping(value = "/pageAdmin", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "后台获取用户的外链icon列表", notes = "后台获取用户的外链icon列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<Page<ExternalLinkIconPageAdminVO>> pageAdmin(@Validated @RequestBody ExternalLinkIconPageAdminDTO externalLinkIconPageAdminDTO) {
        return PageResult.success(externalLinkIconService.pageAdmin(externalLinkIconPageAdminDTO));
    }


    @PostMapping(value = "/updateById", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "根据id修改用户的链接", notes = "根据id修改用户的链接", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<ExternalLinkDeleteVO> updateById(@Validated @RequestBody ExternalLinkIconIconUpdateDTO externalLinkUpdateAdminDTO) {
        ExternalLinkDeleteVO externalLinkDeleteVO = new ExternalLinkDeleteVO();
        externalLinkDeleteVO.setResult(externalLinkIconService.updateById(externalLinkUpdateAdminDTO));
        return Result.success(externalLinkDeleteVO);
    }


    @PostMapping(value = "/save", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "新增", notes = "新增", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<ExternalLinkDeleteVO> save(@Validated @RequestBody ExternalLinkIconSaveAdminDTO externalLinkIconSaveAdminDTO) {
        ExternalLinkDeleteVO externalLinkDeleteVO = new ExternalLinkDeleteVO();
        externalLinkDeleteVO.setResult(externalLinkIconService.save(externalLinkIconSaveAdminDTO));
        return Result.success(externalLinkDeleteVO);
    }



}
